import requests
import json

from common.helper import get_request_url, get_request_headers


def list_workspaces():
    response = requests.get(
      url=get_request_url("v1/workspaces"),
      headers=get_request_headers(),
    )
    if response.status_code == 200:
        return json.loads(response.text)
    else:
        print(f"request failed<{response.status_code}>: {response.text}")
        raise Exception("request failed")


if __name__ == "__main__":
    result = list_workspaces()
    print(result)
